<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="stylesheet" type="text/css" href="{{CDN}}/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="{{CDN}}/easyui/themes/icon.css">
		<script type="text/javascript" src="{{CDN}}/easyui/jquery.min.js"></script>
		<script type="text/javascript" src="{{CDN}}/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="{{CDN}}/easyui/locale/easyui-lang-zh_CN.js"></script>
		<script>
		$(function(){
			/*表格初始化*/
			$('#tree').tree({    
				url:'/newDict/dictCompanyQualifi/getDictCompanyQualifiList'   
			});
			
			
			
			//添加按钮
			$("#add_btn").click(function(){
				$("#add_dialog").dialog({ 
					title: '添加',    
					width: 400,    
					height: 200,    
					closed: false,    
					cache: false,
			   		modal: true,
			   		buttons:[{
						text:'保存',
						iconCls:'icon-save',
						handler:function(){
							$.post("/commonDict/dataSource/insertDataSource",parent.getFormJson($('#add_form')),function(response){
								if(response != 1){
									$.messager.alert('提示','添加了'+response+'条数据');
								}
								$("#add_dialog").dialog('close');
								$("#grid").datagrid('reload');
							})
						}
					}]
				});
			});
			
			
			//修改按钮
			$("#edit_btn").click(function(){
				var rows = $('#grid').datagrid('getSelections');
				if(rows.length<1){
					$.messager.alert('提示','请勾选一条');
					return false;
				}
				
				$("#edit_data_source_id").textbox("setValue", rows[0].data_source_id);
				$("#edit_data_source_code").textbox("setValue", rows[0].data_source_code);
				$("#edit_data_source_name").textbox("setValue", rows[0].data_source_name);
				
				$("#edit_dialog").dialog({ 
					title: '修改',    
					width: 400,    
					height: 300,    
					closed: false,    
					cache: false,
			   		modal: true,
			   		buttons:[{
						text:'保存',
						iconCls:'icon-save',
						handler:function(){
							
							$.post("/commonDict/dataSource/updateDataSource",parent.getFormJson($('#edit_form')),function(response){
								
								$.messager.alert('提示','修改了'+response+'条数据');
								
								$("#edit_dialog").dialog('close');
								$("#grid").datagrid('reload');
							})
						
						}
					}]
				});
				
			});
			
			
		});
			
		
		
		</script>
	</head>
	<body class="easyui-layout">
		<!-- 主表格 -->
		<div region="center" border="false">
			<!--
				<a href="#" id="search_btn" class="easyui-linkbutton"	 data-options="iconCls:'icon-search'"  >查询</a>
				<a href="#" id='add_btn' class="easyui-linkbutton" data-options="iconCls:'icon-add'">新增</a>
				<a href="#" id='edit_btn' class="easyui-linkbutton" data-options="iconCls:'icon-edit'">编辑</a>
			-->
			<ul id="tree"></ul> 
		</div>
		
		
		<!-- 一些隐藏的对话框 -->
		<!-- 新增子类页 -->
		<div style="display:none" id="add_dialog">
			<form id ="add_form" method="post" >
				<table width="100%">
					<tr>
						<td align="right" width="20%">数据源编码:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"   name="data_source_code" style="width:300px"  />
						</td>
					<tr>
					</tr>
						<td align="right" width="20%">数据源名称:</td>
						<td width="20%"  align="left">
							<select class="easyui-textbox"   name="data_source_name" style="width:300px">
						</td>
						<td width="20%" ></td>
					</tr>
				</table> 
			</form>
		</div>
		
		<div style="display:none" id="edit_dialog">
			<form id ="edit_form" method="post" >   
				<table width="100%">
					
					<tr style="display:none">
						<td align="right" width="20%">数据源id:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"  id="edit_data_source_id"  name="data_source_id" style="width:300px"  />
						</td>
					<tr>
					
					<tr>
						<td align="right" width="20%">数据源编码:</td>
						<td width="20%"  align="left" >
							<input class="easyui-textbox"  id="edit_data_source_code"  name="data_source_code" style="width:300px"  />
						</td>
					<tr>
					</tr>
						<td align="right" width="20%">数据源名称:</td>
						<td width="20%"  align="left">
							<select class="easyui-textbox"  id="edit_data_source_name" name="data_source_name" panelHeight='auto'  style="width:300px">
						</td>
						<td width="20%" ></td>
					</tr>
				</table> 
			</form>
		</div> 
		
	</body>
</html>
